<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <div>注意：只能用浏览器下载！！</div>
      <s-table
        ref="table"
        rowKey="id"
        size="middle"
        :scroll="{ x: 1000 }"
        :columns="columns"
        :alert="options.alert"
        :data="loadData">
        <template slot="action" slot-scope="text, record">
          <a :href="$getFileAccessHttpUrl(record.downloadPath)" v-wx-role="51101" target="_blank">
            <a-icon type="edit"/>
            下载 </a>
          <a-divider type="vertical"/>
        </template>
      </s-table>
    </div>
  </a-card>
</template>

<script>
  import { STable, Ellipsis } from '@/components'
  import { postAction } from '@/api/manage'
  import { mixin } from '@/utils/mixin'

  export default {
    name: 'WorkAttendanceHolidaysList',
    mixins: [mixin],
    components: { STable, Ellipsis },
    data () {
      return {
        visible: false,
        // 表头
        // 如果需要字典，那么需要在columns列中加入 customRender: (text) => this.$sysDictFilter(text, 'xxxx')xxxx 为dataIndex
        columns: [
          {
            title: '路径',
            width: 600,
            dataIndex: 'path'
          },
          {
            title: '大小',
            width: 150,
            dataIndex: 'size'
          },
          {
            title: '时间',
            width: 250,
            dataIndex: 'createtime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            scopedSlots: { customRender: 'action' }
          }
        ],
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          return postAction(this.url.list, Object.assign(parameter))
            .then(res => {
              return res.result
            })
        },
        options: {
        },
        url: {
          list: '/system/db/list'
        }
      }
    },
    methods: {
      downloadDatabase (record) {
        console.log(record)
        this.$router.push(record.downloadPath)
      }
    },
    watch: {}
  }
</script>
<style scoped>
</style>
